<?php
namespace app\newtest\controller;

use think\Request;
use think\Db;

// 类名要和文件名一样
class Test {
  public function getTest () {
    $request = Request::instance();
    // return json($request->get());
    // Db::name('user')->insert($request->post());

    // Db::connect('mysql://php_0814:php_0814@127.0.0.1:3306/php_0814#utf8');
    // Db::execute('insert into php_user (id, name) values (?, ?)',[8,'thinkphp']);
    // Db::execute('insert into php_user (name) values (?)',[$request->post().name]);
    $postData = $request->post();
    // var_dump($postData['name']);
    // Db::execute('insert into php_user (name) values (?)', [$postData['name']]);
    $data = Db::table('php_user')->where('id', 9)->find();
    // var_dump($data);
    // return json($request->post());
    return json($data['name']);
  }
}